<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Docker基础 | 辉辉的学习基地</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="icon" href="/blog/favicon.ico">
    <meta name="description" content="辉辉的学习基地是辉辉的个人博客，用于记录学习笔记、分享音乐、书籍、旅行等个人兴趣的站点。">
    <meta name="keywords" content="辉辉,辉辉的博客,博客,个人博客,vue,vuejs,vuepress,vuepress-theme-reco">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/blog/assets/css/0.styles.bbb0eee4.css" as="style"><link rel="preload" href="/blog/assets/js/app.4c41a59b.js" as="script"><link rel="preload" href="/blog/assets/js/2.a039f8e7.js" as="script"><link rel="preload" href="/blog/assets/js/26.37e22ab7.js" as="script"><link rel="preload" href="/blog/assets/js/4.bae9b8d2.js" as="script"><link rel="prefetch" href="/blog/assets/js/10.969d578d.js"><link rel="prefetch" href="/blog/assets/js/11.f93921d3.js"><link rel="prefetch" href="/blog/assets/js/12.a794f274.js"><link rel="prefetch" href="/blog/assets/js/13.d33e075d.js"><link rel="prefetch" href="/blog/assets/js/14.4da4367b.js"><link rel="prefetch" href="/blog/assets/js/15.bd9bf192.js"><link rel="prefetch" href="/blog/assets/js/16.318edc0e.js"><link rel="prefetch" href="/blog/assets/js/17.ebff9194.js"><link rel="prefetch" href="/blog/assets/js/18.17c4bd0a.js"><link rel="prefetch" href="/blog/assets/js/19.3a3638ec.js"><link rel="prefetch" href="/blog/assets/js/20.a1758358.js"><link rel="prefetch" href="/blog/assets/js/21.e2937215.js"><link rel="prefetch" href="/blog/assets/js/22.044317b3.js"><link rel="prefetch" href="/blog/assets/js/23.da1cba87.js"><link rel="prefetch" href="/blog/assets/js/24.8906d05f.js"><link rel="prefetch" href="/blog/assets/js/25.8c51032b.js"><link rel="prefetch" href="/blog/assets/js/27.a9db888c.js"><link rel="prefetch" href="/blog/assets/js/28.d5f797ba.js"><link rel="prefetch" href="/blog/assets/js/29.b316a480.js"><link rel="prefetch" href="/blog/assets/js/3.a38811c1.js"><link rel="prefetch" href="/blog/assets/js/30.6daf7445.js"><link rel="prefetch" href="/blog/assets/js/31.a2aab18e.js"><link rel="prefetch" href="/blog/assets/js/32.e1bb66d4.js"><link rel="prefetch" href="/blog/assets/js/33.53b2c8e5.js"><link rel="prefetch" href="/blog/assets/js/34.20d63ca4.js"><link rel="prefetch" href="/blog/assets/js/35.f06bac5f.js"><link rel="prefetch" href="/blog/assets/js/36.620f1a31.js"><link rel="prefetch" href="/blog/assets/js/37.88e5acfc.js"><link rel="prefetch" href="/blog/assets/js/38.f8c44d81.js"><link rel="prefetch" href="/blog/assets/js/39.bff4d281.js"><link rel="prefetch" href="/blog/assets/js/40.3d371cdd.js"><link rel="prefetch" href="/blog/assets/js/41.4b538139.js"><link rel="prefetch" href="/blog/assets/js/5.80fcdcaf.js"><link rel="prefetch" href="/blog/assets/js/6.e7d0e536.js"><link rel="prefetch" href="/blog/assets/js/7.de89b9df.js"><link rel="prefetch" href="/blog/assets/js/8.4d1ad321.js"><link rel="prefetch" href="/blog/assets/js/9.e842551c.js">
    <link rel="stylesheet" href="/blog/assets/css/0.styles.bbb0eee4.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container have-rightmenu" data-v-f848d4e8><div class="global-loading-wrapper" data-v-137da995 data-v-f848d4e8 data-v-f848d4e8><div class="loader-main" data-v-137da995><img src="/blog/assets/img/loading.18d75e19.gif" alt="loading" data-v-137da995></div></div> <div class="hide" data-v-f848d4e8><header class="navbar" data-v-f848d4e8><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/blog/" class="home-link router-link-active"><span class="site-name">辉辉的学习基地</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">选择模式</h4> <ul class="color-mode-options"><li class="dark">深色模式</li><li class="light active">浅色模式</li><li class="read">阅读模式</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <ul class="suggestions" style="display:none;"></ul></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/blog/" class="nav-link"><i class="iconfont reco-home"></i>首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i></i>后端
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>文档教程</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/blog/docs/nav/" class="nav-link"><i class="iconfont reco-blog"></i>资源导航
</a></li><li class="dropdown-subitem"><a href="/blog/docs/spring/" class="nav-link"><i class="iconfont reco-blog"></i>Spring官网
</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-api"></i>索引
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/categories/" class="nav-link"><i class="iconfont reco-category"></i>分类
</a></li><li class="dropdown-item"><!----> <a href="/blog/tags/" class="nav-link"><i class="iconfont reco-tag"></i>标签
</a></li><li class="dropdown-item"><!----> <a href="/blog/archives/" class="nav-link"><i class="iconfont reco-date"></i>归档
</a></li></ul></div></div><div class="nav-item"><a href="/blog/bookshop/message-board/" class="nav-link"><i class="iconfont reco-suggestion"></i>留言板
</a></div><div class="nav-item"><a href="/blog/docs/nav/" class="nav-link"><i class="iconfont reco-api"></i>资源导航
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>关于
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>联系</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/YanHui-Yang" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="/blog/bookshop/linkme/" class="nav-link"><i class="iconfont reco-account"></i>关于我
</a></li></ul></li><li class="dropdown-item"><h4>博客</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/YanHui-Yang/blog" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>本站源码
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>其他</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/blog/bookshop/friendslink/" class="nav-link"><i class="iconfont reco-friend"></i>友情链接
</a></li></ul></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-f848d4e8></div> <aside class="sidebar" data-v-f848d4e8><div class="personal-info-wrapper" data-v-2cb066a4 data-v-f848d4e8><img src="/blog/img/logo.png" alt="author-avatar" class="personal-img" data-v-2cb066a4> <div class="author" data-v-2cb066a4>
    辉辉
  </div> <div class="personal-info-details" data-v-2cb066a4><div data-v-2cb066a4>文章：<span data-v-2cb066a4>19</span></div> <div data-v-2cb066a4>地点：<span data-v-2cb066a4>广东·广州</span></div></div> <div class="slogan" data-v-2cb066a4>
    Just do it
  </div> <ul class="social-links" data-v-2cb066a4><li class="social-item" data-v-2cb066a4><i class="iconfont reco-github" style="color:#24292e;" data-v-2cb066a4></i></li><li class="social-item" data-v-2cb066a4><i class="iconfont reco-csdn" style="color:#ff4d4d;" data-v-2cb066a4></i></li></ul></div> <nav class="nav-links"><div class="nav-item"><a href="/blog/" class="nav-link"><i class="iconfont reco-home"></i>首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i></i>后端
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>文档教程</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/blog/docs/nav/" class="nav-link"><i class="iconfont reco-blog"></i>资源导航
</a></li><li class="dropdown-subitem"><a href="/blog/docs/spring/" class="nav-link"><i class="iconfont reco-blog"></i>Spring官网
</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-api"></i>索引
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/categories/" class="nav-link"><i class="iconfont reco-category"></i>分类
</a></li><li class="dropdown-item"><!----> <a href="/blog/tags/" class="nav-link"><i class="iconfont reco-tag"></i>标签
</a></li><li class="dropdown-item"><!----> <a href="/blog/archives/" class="nav-link"><i class="iconfont reco-date"></i>归档
</a></li></ul></div></div><div class="nav-item"><a href="/blog/bookshop/message-board/" class="nav-link"><i class="iconfont reco-suggestion"></i>留言板
</a></div><div class="nav-item"><a href="/blog/docs/nav/" class="nav-link"><i class="iconfont reco-api"></i>资源导航
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>关于
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>联系</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/YanHui-Yang" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="/blog/bookshop/linkme/" class="nav-link"><i class="iconfont reco-account"></i>关于我
</a></li></ul></li><li class="dropdown-item"><h4>博客</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/YanHui-Yang/blog" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>本站源码
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>其他</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/blog/bookshop/friendslink/" class="nav-link"><i class="iconfont reco-friend"></i>友情链接
</a></li></ul></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><a href="/blog/pages/0b14441b8c361/" aria-current="page" class="active sidebar-link">Docker基础</a></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper bg-style-3"><div class="articleInfo-wrap" data-v-13f19dad><div class="articleInfo" data-v-13f19dad><ul class="breadcrumbs" data-v-13f19dad><li data-v-13f19dad><a href="/blog/" title="首页" class="fa fa-laptop-house router-link-active" data-v-13f19dad></a></li> <li data-v-13f19dad><a href="/blog/categories/?category=%E5%AE%B9%E5%99%A8%E5%8C%96%E6%8A%80%E6%9C%AF" title="分类" data-v-13f19dad>容器化技术</a></li> <!----> <!----></ul> <div class="info" data-v-13f19dad><div title="作者" class="author fa fa-user" data-v-13f19dad><a href="javascript:;" data-v-13f19dad>辉辉</a></div> <div title="创建时间" class="date fa fa-calendar-alt" data-v-13f19dad><a href="javascript:;" data-v-13f19dad>2021/10/04 11:50:11</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-content"></div></div></div> <h1><img src="">
            Docker基础
          </h1> <div class="theme-vdoing-content content__default"><h2 id="_1-docker-的优势"><a href="#_1-docker-的优势" class="header-anchor">#</a> 1. Docker 的优势</h2> <ul><li><p><strong>环境一致、高效迁移</strong></p> <p>如： 我们一个java Web应用程序涉及很多东西，比如jdk、tomcat、mysql等软件环境。当这些其中某一项版本不一致的时候，可能就会导致应用程序跑不起来这种情况。Docker则将程序以及使用软件环境直接绑定在一起，无论在那个机器上保证了环境一致。</p></li> <li><p><strong>进程级隔离、容器独立</strong></p> <p>如： 服务器自己的程序挂了，结果发现是别人程序出了问题把内存吃完了，自己程序因为内存不够就挂了这种也是一种比较常见的情况，如果你的程序重要性不是特别高的话，公司基本上不可能让你的程序独享一台服务器的，这时候你的服务器就会跟公司其他人的程序共享一台服务器，所以不可避免地就会受到其他程序的干扰，导致自己的程序出现问题。Docker就很好解决了环境隔离的问题，别人程序不会影响到自己的程序。</p></li> <li><p><strong>镜像机制、便于部署</strong></p> <p>公司要弄一个活动，可能会有大量的流量进来，公司需要再多部署几十台服务器。在没有Docker的情况下，要在几天内部署几十台服务器，这对运维来说是一件非常折磨人的事，而且每台服务器的环境还不一定一样，就会出现各种问题，最后部署地头皮发麻。用Docker的话，我只需要将程序打包到镜像，你要多少台服务，我就给跑多少容器，极大地提高了部署效率。</p></li></ul> <hr> <h2 id="_2-docker-的安装"><a href="#_2-docker-的安装" class="header-anchor">#</a> 2. Docker 的安装</h2> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">curl</span> -fsSL get.docker.com -o get-docker.sh
<span class="token function">sudo</span> <span class="token function">sh</span> get-docker.sh --mirror Aliyun
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul><li>启动 Docker</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> systemctl <span class="token builtin class-name">enable</span> docker
<span class="token function">sudo</span> systemctl start docker
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul><li>创建docker用户组</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">groupadd</span> docker
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>将当前用户加入docker组</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">usermod</span> -aG docker <span class="token environment constant">$USER</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>测试docker安装是否正确</li></ul> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code>docker run hello-world
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><strong>配置阿里云加速</strong></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">mkdir</span> -p /etc/docker
<span class="token function">sudo</span> <span class="token function">tee</span> /etc/docker/daemon.json <span class="token operator">&lt;&lt;-</span><span class="token string">'EOF'
{
  &quot;registry-mirrors&quot;: [&quot;https://knys0jq1.mirror.aliyuncs.com&quot;]
}
EOF</span>
<span class="token function">sudo</span> systemctl daemon-reload
<span class="token function">sudo</span> systemctl restart docker
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><hr> <h2 id="_3-docker-基本指令"><a href="#_3-docker-基本指令" class="header-anchor">#</a> 3. Docker 基本指令</h2> <h3 id="_3-1-镜像指令"><a href="#_3-1-镜像指令" class="header-anchor">#</a> 3.1 镜像指令</h3> <div class="language-markdown line-numbers-mode"><pre class="language-markdown"><code><span class="token title important"><span class="token punctuation">#</span> 1.查看本机中所有镜像</span>
docker images
	-a: 列出所有
	-q: 只显示镜像id
docker images tomcat(镜像名称)		只列出该名称的镜像

<span class="token title important"><span class="token punctuation">#</span> 2.搜索镜像</span>
docker search 镜像名		去docker hub上查询镜像
	--no-trunc: 显示完整的镜像信息

<span class="token title important"><span class="token punctuation">#</span> 3.拉取镜像</span>
docker pull 镜像名[:version]

<span class="token title important"><span class="token punctuation">#</span> 4.删除镜像</span>
docker rmi 镜像名
	-f: 强制删除
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><h3 id="_3-2-容器命令"><a href="#_3-2-容器命令" class="header-anchor">#</a> 3.2 容器命令</h3> <div class="language-markdown line-numbers-mode"><pre class="language-markdown"><code><span class="token title important"><span class="token punctuation">#</span> 1.运行容器</span>
docker run 镜像名:tag
	--name: 容器别名
	-d: 后台启动
	-p: 端口映射	宿主机端口号:容器端口号
	--rm: 临时容器(退出之后容器会被删除)
	--restart always: 在docker启动的时候启动该容器

<span class="token title important"><span class="token punctuation">#</span> 2.查看运行的容器</span>
docker ps	查看正在运行的容器
	-a: 查看所有容器
	-q: 只显示容器id

<span class="token title important"><span class="token punctuation">#</span> 3.停止|关闭|重启|暂停|恢复|容器</span>
docker start 容器名字或容器id
docker restart 容器名或容器id
docker stop 容器名或容器id
docker kill 容器名或容器id
docker pause|unpause 容器名或容器id

<span class="token title important"><span class="token punctuation">#</span> 4.删除容器</span>
docker rm -f 容器id和容器名
docker rm -f $(docker ps -aq)	删除所有容器

<span class="token title important"><span class="token punctuation">#</span> 5.查看容器内进程</span>
docker top 容器id或容器名

<span class="token title important"><span class="token punctuation">#</span> 6.查看查看容器内部细节</span>
docker inspect 容器id或容器名

<span class="token title important"><span class="token punctuation">#</span> 7.查看容器的运行日志</span>
docker logs [OPTIONS] 容器id或容器名
	-t: 加入时间戳
	-f: 实时日志
	--tail 数字: 显示最后多少条日志

<span class="token title important"><span class="token punctuation">#</span> 8.进入容器内部</span>
docker exec 容器id 容器内命令
	-i: 以交互模式运行容器
	-t: 分配一个伪终端
	bash: shell窗口

<span class="token title important"><span class="token punctuation">#</span> 9.容器和宿主机之间复制文件</span>
docker cp 文件|目录 容器id:容器路径				将宿主机复制到容器内部
docker cp 容器id:容器内资源路径 宿主机目录路径		将容器内资源拷贝到主机上

<span class="token title important"><span class="token punctuation">#</span> 10.数据卷(volume)实现与宿主机共享目录</span>
docker run -v 宿主机路径|任意别名:容器内的路径 镜像名
	1.宿主机路径: 必须是绝对路径，宿主机目录会覆盖容器内目录内容
	2.任意别名: 容器目录文件复制到宿主机中

<span class="token title important"><span class="token punctuation">#</span> 11.打包镜像</span>
docker save 镜像名 -o 名称.tar

<span class="token title important"><span class="token punctuation">#</span> 12.载入镜像</span>
docker load -i 名称.tar

<span class="token title important"><span class="token punctuation">#</span> 13.容器打包成新的镜像</span>
docker commit -m &quot;描述信息&quot; -a &quot;作者信息&quot; 容器id或者名称 打包的镜像名称:标签

<span class="token title important"><span class="token punctuation">#</span> 14.推送镜像到远程docker hub</span>
	1.登录docker hub 注册自己账号
	2.登录网页版docker hub
	3.在docker命令行界面登录docker hub
		<span class="token code-snippet code keyword">`docker login`</span> 按照提示输入用户名  输入密码
	4.给本地仓库提交镜像打一个tag标签
		docker tag 原始镜像id|原始镜像名称:tag 注册账号/镜像名称:版本
	5.推送镜像
		docker push 注册账号/镜像名称:版本
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br></div></div><hr> <h2 id="_4-docker-安装常见服务"><a href="#_4-docker-安装常见服务" class="header-anchor">#</a> 4. Docker 安装常见服务</h2> <h3 id="_4-1-安装-mysql"><a href="#_4-1-安装-mysql" class="header-anchor">#</a> 4.1 安装 MySQL</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>docker pull mysql

docker run --name mysql_server -p <span class="token number">3306</span>:3306 -v /usr/mydata/mysql/data:/var/lib/mysql -e <span class="token assign-left variable">MYSQL_ROOT_PASSWORD</span><span class="token operator">=</span><span class="token number">123456</span> -d mysql
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="_4-2-安装-tomcat"><a href="#_4-2-安装-tomcat" class="header-anchor">#</a> 4.2 安装 Tomcat</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>docker pull tomcat

docker run -p <span class="token number">8080</span>:8080 -v my_tomcat_volumn:/usr/local/tomcat/webapps -d --name tomcat_server tomcat
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><hr> <h2 id="_5-dockerfile"><a href="#_5-dockerfile" class="header-anchor">#</a> 5. Dockerfile</h2> <h3 id="dockerfile-基础语法"><a href="#dockerfile-基础语法" class="header-anchor">#</a> Dockerfile 基础语法</h3> <p>作用: 用来构建docker镜像的文件</p> <p><img src="https://gitee.com/YanHui-Yang/blog-img/raw/master/img/image-20211009140508234.png" alt="image-20211009140508234"></p> <table><thead><tr><th>保留字</th> <th>作用</th></tr></thead> <tbody><tr><td><strong>FROM</strong></td> <td><strong>当前镜像是基于哪个镜像构建</strong> <code>第一个指令必须是FROM</code></td></tr> <tr><td>MAINTAINER</td> <td>镜像维护者的姓名和邮箱地址  废弃</td></tr> <tr><td><strong>RUN</strong></td> <td><strong>构建镜像时需要运行的指令</strong></td></tr> <tr><td><strong>EXPOSE</strong></td> <td><strong>当前容器对外暴露出的端口号</strong></td></tr> <tr><td><strong>WORKDIR</strong></td> <td><strong>指定在创建容器后，终端默认登录进来的工作目录，一个落脚点</strong></td></tr> <tr><td><strong>ADD</strong></td> <td><strong>将宿主机目录下的文件拷贝进镜像且ADD命令会自动处理URL和解压tar包</strong></td></tr> <tr><td><strong>COPY</strong></td> <td><strong>类似于ADD，拷贝文件和目录到镜像中<br>将从构建上下文目录中&lt;原路径&gt;的文件/目录复制到新的一层的镜像内的&lt;目标路径&gt;位置</strong></td></tr> <tr><td><strong>ENV</strong></td> <td><strong>用来在构建镜像过程中设置环境变量</strong></td></tr> <tr><td><strong>VOLUME</strong></td> <td><strong>容器数据卷，用于数据保存和持久化工作</strong>  docker -v /root/data:/usr/local/tomcat/webapps</td></tr> <tr><td><strong>CMD</strong></td> <td><strong>指定一个容器启动时要运行的命令<br>Dockerfile中可以有多个CMD指令，但只有最后一个生效，CMD会被docker run之后的参数替换</strong></td></tr> <tr><td><strong>ENTRYPOINT</strong></td> <td><strong>指定一个容器启动时要运行的命令<br>ENTRYPOINT的目的和CMD一样，都是在指定容器启动程序及其参数</strong></td></tr></tbody></table> <h4 id="from-命令"><a href="#from-命令" class="header-anchor">#</a> FROM 命令</h4> <ul><li><p>基于那个镜像进行构建新的镜像,在构建时会自动从 docker hub 拉取 base 镜像 必须作为 Dockerfile 的第一个指令出现</p></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">FROM</span> &lt;image&gt;</span>
<span class="token instruction"><span class="token keyword">FROM</span> &lt;image&gt;[:&lt;tag&gt;]     使用版本不写为latest</span>
<span class="token instruction"><span class="token keyword">FROM</span> &lt;image&gt;[@&lt;digest&gt;]  使用摘要</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></li></ul> <h4 id="maintainer-命令"><a href="#maintainer-命令" class="header-anchor">#</a> MAINTAINER  命令</h4> <ul><li><p>镜像维护者的姓名和邮箱地址[废弃]</p></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">MAINTAINER</span> &lt;name&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ul> <h4 id="run-命令"><a href="#run-命令" class="header-anchor">#</a> RUN 命令</h4> <ul><li><p>RUN 指令将在当前映像之上的新层中执行任何命令并提交结果。生成的提交映像将用于 Dockerfile 中的下一步</p></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">RUN</span> &lt;command&gt; (shell form, the command is run in a shell, which by default is /bin/sh -c on Linux or cmd /S /C on Windows)</span>
<span class="token instruction"><span class="token keyword">RUN</span> echo hello</span>

<span class="token instruction"><span class="token keyword">RUN</span> [<span class="token string">&quot;executable&quot;</span>, <span class="token string">&quot;param1&quot;</span>, <span class="token string">&quot;param2&quot;</span>] (exec form)</span>
<span class="token instruction"><span class="token keyword">RUN</span> [<span class="token string">&quot;/bin/bash&quot;</span>, <span class="token string">&quot;-c&quot;</span>, <span class="token string">&quot;echo hello&quot;</span>]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></li></ul> <h4 id="expose-命令"><a href="#expose-命令" class="header-anchor">#</a> EXPOSE 命令</h4> <ul><li><p>用来指定构建的镜像在运行为容器时对外暴露的端口</p> <ul><li><code>注意: 仅仅是一个说明</code></li></ul> <p>Tomcat Dockerfile: EXPOSE 3306  ==&gt; docker run -p 宿主机端口:8080</p> <p>MYSQL  Dockerfile: EXPOSE 3306</p> <p>RabbitMQ: Dockerfile: EXPOSE 5672 15672</p></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">EXPOSE</span> 80/tcp  如果没有显示指定则默认暴露都是tcp</span>
<span class="token instruction"><span class="token keyword">EXPOSE</span> 80/udp</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></li></ul> <h4 id="cmd-命令"><a href="#cmd-命令" class="header-anchor">#</a> CMD 命令</h4> <ul><li><p>用来为启动的容器指定执行的命令，在 Dockerfile 中只能有一条 CMD 指令。如果列出多个命令，则只有最后一个命令才会生效。</p></li> <li><p>注意: <strong>Dockerfile 中只能有一条 CMD 指令。如果列出多个命令，则只有最后一个命令才会生效。</strong></p></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">CMD</span> [<span class="token string">&quot;executable&quot;</span>,<span class="token string">&quot;param1&quot;</span>,<span class="token string">&quot;param2&quot;</span>] (exec form, this is the preferred form)</span>
<span class="token instruction"><span class="token keyword">CMD</span> [<span class="token string">&quot;param1&quot;</span>,<span class="token string">&quot;param2&quot;</span>] (as default parameters to ENTRYPOINT)</span>
<span class="token instruction"><span class="token keyword">CMD</span> command param1 param2 (shell form)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></li></ul> <h4 id="workdir-命令"><a href="#workdir-命令" class="header-anchor">#</a> WORKDIR 命令</h4> <ul><li><p>用来为 Dockerfile 中的任何 RUN、CMD、ENTRYPOINT、COPY 和 ADD 指令设置工作目录。如果 WORKDIR 不存在，即使它没有在任何后续 Dockerfile 指令中使用，它也将被创建。</p></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">WORKDIR</span> /path/to/workdir</span>

<span class="token instruction"><span class="token keyword">WORKDIR</span> /a</span>
<span class="token instruction"><span class="token keyword">WORKDIR</span> b  /a/b </span>
<span class="token instruction"><span class="token keyword">WORKDIR</span> c  /a/b/c</span>
`注意:WORKDIR指令可以在Dockerfile中多次使用。如果提供了相对路径，则该路径将与先前WORKDIR指令的路径相对`
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></li></ul> <h4 id="env-命令"><a href="#env-命令" class="header-anchor">#</a> ENV 命令</h4> <ul><li><p>用来为构建镜像设置环境变量。这个值将出现在构建阶段中所有后续指令的环境中。</p></li> <li><p>语法：</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">ENV</span> &lt;key&gt; &lt;value&gt;</span>
<span class="token instruction"><span class="token keyword">ENV</span> &lt;key&gt;=&lt;value&gt; ...</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></li></ul> <h4 id="add-命令"><a href="#add-命令" class="header-anchor">#</a> ADD 命令</h4> <ul><li><p>用来从 context 上下文复制新文件、目录或远程文件 url，并将它们添加到位于指定路径的映像文件系统中。</p></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">ADD</span> hom* /mydir/       通配符添加多个文件</span>
<span class="token instruction"><span class="token keyword">ADD</span> hom?.txt /mydir/   通配符添加</span>
<span class="token instruction"><span class="token keyword">ADD</span> test.txt relativeDir/  可以指定相对路径</span>
<span class="token instruction"><span class="token keyword">ADD</span> test.txt /absoluteDir/ 也可以指定绝对路径</span>
<span class="token instruction"><span class="token keyword">ADD</span> url </span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></li></ul> <h4 id="copy-命令"><a href="#copy-命令" class="header-anchor">#</a> COPY 命令</h4> <ul><li><p>用来将 context 目录中指定文件复制到镜像的指定目录中</p></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">COPY</span> src dest</span>
<span class="token instruction"><span class="token keyword">COPY</span> [<span class="token string">&quot;&lt;src&gt;&quot;</span>,... <span class="token string">&quot;&lt;dest&gt;&quot;</span>]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></li></ul> <h4 id="volume-命令"><a href="#volume-命令" class="header-anchor">#</a> VOLUME 命令</h4> <p>tomcat: /usr/local/tomcat/webapps</p> <p>mysql: /var/lib/mysql</p> <p>docker run -v 宿主机目录:/容器中目录</p> <ul><li><p>用来定义容器运行时可以挂在到宿主机的目录</p> <ul><li><code>注意:这个volume也是一个说明</code></li></ul></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">VOLUME</span> [<span class="token string">&quot;/data&quot;</span>]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ul> <h4 id="entrypoint命令"><a href="#entrypoint命令" class="header-anchor">#</a> ENTRYPOINT命令</h4> <ul><li><p>用来指定容器启动时执行命令和 CMD 类似</p></li> <li><p>语法:</p> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">ENTRYPOINT</span> [<span class="token string">&quot;executable&quot;</span>, <span class="token string">&quot;param1&quot;</span>, <span class="token string">&quot;param2&quot;</span>]</span>
<span class="token instruction"><span class="token keyword">ENTRYPOINT</span> command param1 param2</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>ENTRYPOINT 指令，往往用于设置容器启动后的<strong>第一个命令</strong>，这对一个容器来说往往是固定的。
CMD 指令，往往用于设置容器启动的第一个命令的<strong>默认参数</strong>，这对一个容器来说可以是变化的。</p></li></ul> <h3 id="实战-使用-dockerfile-构建项目"><a href="#实战-使用-dockerfile-构建项目" class="header-anchor">#</a> 实战：使用 Dockerfile 构建项目</h3> <div class="language-dockerfile line-numbers-mode"><pre class="language-dockerfile"><code><span class="token instruction"><span class="token keyword">FROM</span> openjdk:8</span>
<span class="token instruction"><span class="token keyword">WORKDIR</span> /dockerfile_demo</span>
<span class="token instruction"><span class="token keyword">ADD</span> dockerfile.jar /dockerfile_demo</span>
<span class="token instruction"><span class="token keyword">EXPOSE</span> 8080</span>
<span class="token instruction"><span class="token keyword">ENTRYPOINT</span> [<span class="token string">&quot;java&quot;</span>, <span class="token string">&quot;-jar&quot;</span>]</span>
<span class="token instruction"><span class="token keyword">CMD</span> [<span class="token string">&quot;dockerfile.jar&quot;</span>]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h2 id="_6-docker-compose"><a href="#_6-docker-compose" class="header-anchor">#</a> 6. Docker Compose</h2> <h3 id="_6-1-docker-compose-安装与使用"><a href="#_6-1-docker-compose-安装与使用" class="header-anchor">#</a> 6.1 Docker Compose 安装与使用</h3> <p>docker compose: 称之为docker 容器编排工具</p> <p>Docker Compose 安装</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">curl</span> -L https://github.com/docker/compose/releases/download/1.25.5/docker-compose-<span class="token variable"><span class="token variable">`</span><span class="token function">uname</span> -s<span class="token variable">`</span></span>-<span class="token variable"><span class="token variable">`</span><span class="token function">uname</span> -m<span class="token variable">`</span></span> <span class="token operator">&gt;</span> /usr/local/bin/docker-compose

<span class="token function">chmod</span> +x /usr/local/bin/docker-compose

<span class="token function">curl</span> -L https://raw.githubusercontent.com/docker/compose/1.25.5/contrib/completion/bash/docker-compose <span class="token operator">&gt;</span> /etc/bash_completion.d/docker-compose
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>docker-compose.yml</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>version: <span class="token string">&quot;3.0&quot;</span>
services:
  mysqldb:
    image: mysql:8.0.26
    container_name: mysql
    ports:
      - <span class="token string">&quot;3306:3306&quot;</span>
    volumes:
      - /root/mysql/conf:/etc/mysql/conf.d
      - /root/mysql/logs:/logs
      - /root/mysql/data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: <span class="token number">123456</span>

  redis:
    image: redis:4.0.14
    container_name: redis
    ports:
      - <span class="token string">&quot;6379:6379&quot;</span>
    volumes:
      - /root/redis/data:/data
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div><div class="language-bash line-numbers-mode"><pre class="language-bash"><code>docker-compose up // 前台启动一组服务
docker-compose up -d // 后台启动一组服务
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="_6-2-docker-compose-模板文件"><a href="#_6-2-docker-compose-模板文件" class="header-anchor">#</a> 6.2 docker-compose 模板文件</h3> <h4 id="build"><a href="#build" class="header-anchor">#</a> <code>build</code></h4> <p>指定 <code>Dockerfile</code> 所在文件夹的路径（可以是绝对路径，或者相对 docker-compose.yml 文件的路径）。 <code>Compose</code> 将会利用它自动构建这个镜像，然后使用这个镜像。</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span>
<span class="token key atrule">services</span><span class="token punctuation">:</span>

  <span class="token key atrule">webapp</span><span class="token punctuation">:</span>
    <span class="token key atrule">build</span><span class="token punctuation">:</span> ./dir
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>你也可以使用 <code>context</code> 指令指定 <code>Dockerfile</code> 所在文件夹的路径</p> <p>使用 <code>dockerfile</code> 指令指定 <code>Dockerfile</code> 文件名</p> <p>使用 <code>arg</code> 指令指定构建镜像时的变量</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span>
<span class="token key atrule">services</span><span class="token punctuation">:</span>

  <span class="token key atrule">webapp</span><span class="token punctuation">:</span>
    <span class="token key atrule">build</span><span class="token punctuation">:</span>
      <span class="token key atrule">context</span><span class="token punctuation">:</span> ./dir
      <span class="token key atrule">dockerfile</span><span class="token punctuation">:</span> Dockerfile<span class="token punctuation">-</span>alternate
      <span class="token key atrule">args</span><span class="token punctuation">:</span>
        <span class="token key atrule">buildno</span><span class="token punctuation">:</span> <span class="token number">1</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h4 id="command"><a href="#command" class="header-anchor">#</a> <code>command</code></h4> <p>覆盖容器启动后默认执行的命令</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">command</span><span class="token punctuation">:</span> echo &quot;hello world&quot;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="container-name"><a href="#container-name" class="header-anchor">#</a> <code>container_name</code></h4> <p>指定容器名称。默认将会使用 <code>项目名称_服务名称_序号</code> 这样的格式</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">container_name</span><span class="token punctuation">:</span> docker<span class="token punctuation">-</span>web<span class="token punctuation">-</span>container
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><blockquote><p>注意: 指定容器名称后，该服务将无法进行扩展（scale），因为 Docker 不允许多个容器具有相同的名称。</p></blockquote> <h4 id="depends-on"><a href="#depends-on" class="header-anchor">#</a> <code>depends_on</code></h4> <p>解决容器的依赖、启动先后的问题。以下例子中会先启动 <code>redis</code> <code>db</code> 再启动 <code>web</code></p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span>

<span class="token key atrule">services</span><span class="token punctuation">:</span>
  <span class="token key atrule">web</span><span class="token punctuation">:</span>
    <span class="token key atrule">build</span><span class="token punctuation">:</span> .
    <span class="token key atrule">depends_on</span><span class="token punctuation">:</span>
      <span class="token punctuation">-</span> db
      <span class="token punctuation">-</span> redis

  <span class="token key atrule">redis</span><span class="token punctuation">:</span>
    <span class="token key atrule">image</span><span class="token punctuation">:</span> redis

  <span class="token key atrule">db</span><span class="token punctuation">:</span>
    <span class="token key atrule">image</span><span class="token punctuation">:</span> postgres
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><blockquote><p>注意：<code>web</code> 服务不会等待 <code>redis</code> <code>db</code> 「完全启动」之后才启动。</p></blockquote> <h4 id="env-file"><a href="#env-file" class="header-anchor">#</a> <code>env_file</code></h4> <p>从文件中获取环境变量，可以为单独的文件路径或列表</p> <p>如果通过 <code>docker-compose -f FILE</code> 方式来指定 Compose 模板文件，则 <code>env_file</code> 中变量的路径会基于模板文件路径</p> <p>如果有变量名称与 <code>environment</code> 指令冲突，则按照惯例，以后者为准</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>env_file: .env

env_file:
  - ./common.env
  - ./apps/web.env
  - /opt/secrets.env
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>环境变量文件中每一行必须符合格式，支持 <code>#</code> 开头的注释行</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># common.env: Set development environment</span>
<span class="token assign-left variable">PROG_ENV</span><span class="token operator">=</span>development
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h4 id="environment"><a href="#environment" class="header-anchor">#</a> <code>environment</code></h4> <p>设置环境变量。你可以使用数组或字典两种格式</p> <p>只给定名称的变量会自动获取运行 Compose 主机上对应变量的值，可以用来防止泄露不必要的数据</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">environment</span><span class="token punctuation">:</span>
  <span class="token key atrule">RACK_ENV</span><span class="token punctuation">:</span> development
  <span class="token key atrule">SESSION_SECRET</span><span class="token punctuation">:</span>

<span class="token key atrule">environment</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> RACK_ENV=development
  <span class="token punctuation">-</span> SESSION_SECRET
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>如果变量名称或者值中用到 <code>true|false，yes|no</code> 等表达 <a href="https://yaml.org/type/bool.html" target="_blank" rel="noopener noreferrer">布尔<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> 含义的词汇，最好放到引号里，避免 YAML 自动解析某些内容为对应的布尔语义。这些特定词汇，包括</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>y<span class="token operator">|</span>Y<span class="token operator">|</span><span class="token function">yes</span><span class="token operator">|</span>Yes<span class="token operator">|</span>YES<span class="token operator">|</span>n<span class="token operator">|</span>N<span class="token operator">|</span>no<span class="token operator">|</span>No<span class="token operator">|</span>NO<span class="token operator">|</span><span class="token boolean">true</span><span class="token operator">|</span>True<span class="token operator">|</span>TRUE<span class="token operator">|</span><span class="token boolean">false</span><span class="token operator">|</span>False<span class="token operator">|</span>FALSE<span class="token operator">|</span>on<span class="token operator">|</span>On<span class="token operator">|</span>ON<span class="token operator">|</span>off<span class="token operator">|</span>Off<span class="token operator">|</span>OFF
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="healthcheck"><a href="#healthcheck" class="header-anchor">#</a> <code>healthcheck</code></h4> <p>通过命令检查容器是否健康运行</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">healthcheck</span><span class="token punctuation">:</span>
  <span class="token key atrule">test</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">&quot;CMD&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;curl&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;-f&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;http://localhost&quot;</span><span class="token punctuation">]</span>
  <span class="token key atrule">interval</span><span class="token punctuation">:</span> 1m30s
  <span class="token key atrule">timeout</span><span class="token punctuation">:</span> 10s
  <span class="token key atrule">retries</span><span class="token punctuation">:</span> <span class="token number">3</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h4 id="image"><a href="#image" class="header-anchor">#</a> <code>image</code></h4> <p>指定为镜像名称或镜像 ID。如果镜像在本地不存在，<code>Compose</code> 将会尝试拉取这个镜像</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">image</span><span class="token punctuation">:</span> ubuntu
<span class="token key atrule">image</span><span class="token punctuation">:</span> orchardup/postgresql
<span class="token key atrule">image</span><span class="token punctuation">:</span> a4bc65fd
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h4 id="networks"><a href="#networks" class="header-anchor">#</a> <code>networks</code></h4> <p>配置容器连接的网络</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">&quot;3&quot;</span>
<span class="token key atrule">services</span><span class="token punctuation">:</span>

  <span class="token key atrule">some-service</span><span class="token punctuation">:</span>
    <span class="token key atrule">networks</span><span class="token punctuation">:</span>
     <span class="token punctuation">-</span> some<span class="token punctuation">-</span>network
     <span class="token punctuation">-</span> other<span class="token punctuation">-</span>network

<span class="token key atrule">networks</span><span class="token punctuation">:</span>
  <span class="token key atrule">some-network</span><span class="token punctuation">:</span>
  <span class="token key atrule">other-network</span><span class="token punctuation">:</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><h4 id="ports"><a href="#ports" class="header-anchor">#</a> <code>ports</code></h4> <p>暴露端口信息</p> <p>使用宿主端口：容器端口 <code>(HOST:CONTAINER)</code> 格式，或者仅仅指定容器的端口（宿主将会随机选择端口）都可以</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">ports</span><span class="token punctuation">:</span>
 <span class="token punctuation">-</span> <span class="token string">&quot;3000&quot;</span>
 <span class="token punctuation">-</span> <span class="token string">&quot;8000:8000&quot;</span>
 <span class="token punctuation">-</span> <span class="token string">&quot;49100:22&quot;</span>
 <span class="token punctuation">-</span> <span class="token string">&quot;127.0.0.1:8001:8001&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p><em>注意：当使用 <code>HOST:CONTAINER</code> 格式来映射端口时，如果你使用的容器端口小于 60 并且没放到引号里，可能会得到错误结果，因为 <code>YAML</code> 会自动解析 <code>xx:yy</code> 这种数字格式为 60 进制。为避免出现这种问题，建议数字串都采用引号包括起来的字符串格式</em></p> <h4 id="sysctls"><a href="#sysctls" class="header-anchor">#</a> <code>sysctls</code></h4> <p>配置容器内核参数</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">sysctls</span><span class="token punctuation">:</span>
  <span class="token key atrule">net.core.somaxconn</span><span class="token punctuation">:</span> <span class="token number">1024</span>
  <span class="token key atrule">net.ipv4.tcp_syncookies</span><span class="token punctuation">:</span> <span class="token number">0</span>

<span class="token key atrule">sysctls</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> net.core.somaxconn=1024
  <span class="token punctuation">-</span> net.ipv4.tcp_syncookies=0
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h4 id="ulimits"><a href="#ulimits" class="header-anchor">#</a> <code>ulimits</code></h4> <p>指定容器的 ulimits 限制值</p> <p>例如，指定最大进程数为 65535，指定文件句柄数为 20000（软限制，应用可以随时修改，不能超过硬限制） 和 40000（系统硬限制，只能 root 用户提高）</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code>  <span class="token key atrule">ulimits</span><span class="token punctuation">:</span>
    <span class="token key atrule">nproc</span><span class="token punctuation">:</span> <span class="token number">65535</span>
    <span class="token key atrule">nofile</span><span class="token punctuation">:</span>
      <span class="token key atrule">soft</span><span class="token punctuation">:</span> <span class="token number">20000</span>
      <span class="token key atrule">hard</span><span class="token punctuation">:</span> <span class="token number">40000</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h4 id="volumes"><a href="#volumes" class="header-anchor">#</a> <code>volumes</code></h4> <p>数据卷所挂载路径设置。可以设置为宿主机路径(<code>HOST:CONTAINER</code>)或者数据卷名称(<code>VOLUME:CONTAINER</code>)，并且可以设置访问模式 （<code>HOST:CONTAINER:ro</code>）</p> <p>该指令中路径支持相对路径</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">volumes</span><span class="token punctuation">:</span>
 <span class="token punctuation">-</span> /var/lib/mysql
 <span class="token punctuation">-</span> cache/<span class="token punctuation">:</span>/tmp/cache
 <span class="token punctuation">-</span> ~/configs<span class="token punctuation">:</span>/etc/configs/<span class="token punctuation">:</span>ro
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>如果路径为数据卷名称，必须在文件中配置数据卷</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">&quot;3&quot;</span>

<span class="token key atrule">services</span><span class="token punctuation">:</span>
  <span class="token key atrule">my_src</span><span class="token punctuation">:</span>
    <span class="token key atrule">image</span><span class="token punctuation">:</span> mysql<span class="token punctuation">:</span><span class="token number">8.0</span>
    <span class="token key atrule">volumes</span><span class="token punctuation">:</span>
      <span class="token punctuation">-</span> mysql_data<span class="token punctuation">:</span>/var/lib/mysql

<span class="token key atrule">volumes</span><span class="token punctuation">:</span>
  <span class="token key atrule">mysql_data</span><span class="token punctuation">:</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><h3 id="_6-3-docker-compose-常用命令"><a href="#_6-3-docker-compose-常用命令" class="header-anchor">#</a> 6.3 docker-compose 常用命令</h3> <h5 id="_1-命令对象与格式"><a href="#_1-命令对象与格式" class="header-anchor">#</a> 1. 命令对象与格式</h5> <p>对于 Compose 来说，大部分命令的对象既可以是项目本身，也可以指定为项目中的服务或者容器。如果没有特别的说明，命令对象将是项目，这意味着项目中所有的服务都会受到命令影响</p> <p>执行 <code>docker-compose [COMMAND] --help</code> 或者 <code>docker-compose help [COMMAND]</code> 可以查看具体某个命令的使用格式</p> <p><code>docker-compose</code> 命令的基本的使用格式是</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>docker-compose <span class="token punctuation">[</span>-f<span class="token operator">=</span><span class="token operator">&lt;</span>arg<span class="token operator">&gt;</span><span class="token punctuation">..</span>.<span class="token punctuation">]</span> <span class="token punctuation">[</span>options<span class="token punctuation">]</span> <span class="token punctuation">[</span>COMMAND<span class="token punctuation">]</span> <span class="token punctuation">[</span>ARGS<span class="token punctuation">..</span>.<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h5 id="_2-命令选项"><a href="#_2-命令选项" class="header-anchor">#</a> 2. 命令选项</h5> <ul><li><code>-f, --file FILE</code> 指定使用的 Compose 模板文件，默认为 <code>docker-compose.yml</code>，可以多次指定</li> <li><code>-p, --project-name NAME</code> 指定项目名称，默认将使用所在目录名称作为项目名</li> <li><code>--x-networking</code> 使用 Docker 的可拔插网络后端特性</li> <li><code>--x-network-driver DRIVER</code> 指定网络后端的驱动，默认为 <code>bridge</code></li> <li><code>--verbose</code> 输出更多调试信息</li> <li><code>-v, --version</code> 打印版本并退出</li></ul> <h5 id="_3-命令使用说明"><a href="#_3-命令使用说明" class="header-anchor">#</a> 3.命令使用说明</h5> <h5 id="up-重点"><a href="#up-重点" class="header-anchor">#</a> <code>up</code>  [重点]</h5> <p>格式为 <code>docker-compose up [options] [SERVICE...]</code></p> <ul><li><p>该命令十分强大，它将尝试自动完成包括构建镜像，（重新）创建服务，启动服务，并关联服务相关容器的一系列操作</p></li> <li><p>链接的服务都将会被自动启动，除非已经处于运行状态</p></li> <li><p>可以说，大部分时候都可以直接通过该命令来启动一个项目</p></li> <li><p>默认情况，<code>docker-compose up</code> 启动的容器都在前台，控制台将会同时打印所有容器的输出信息，可以很方便进行调试</p></li> <li><p>当通过 <code>Ctrl-C</code> 停止命令时，所有容器将会停止</p></li> <li><p>如果使用 <code>docker-compose up -d</code>，将会在后台启动并运行所有的容器。一般推荐生产环境下使用该选项</p></li> <li><p>默认情况，如果服务容器已经存在，<code>docker-compose up</code> 将会尝试停止容器，然后重新创建（保持使用 <code>volumes-from</code> 挂载的卷），以保证新启动的服务匹配 <code>docker-compose.yml</code> 文件的最新内容</p></li></ul> <hr> <h5 id="down-重点"><a href="#down-重点" class="header-anchor">#</a> <code>down</code>  [重点]</h5> <ul><li><p>注意: docker-compose down 关闭所有容器</p></li> <li><p>此命令将会停止 <code>up</code> 命令所启动的容器，并移除网络</p></li></ul> <hr> <h5 id="exec"><a href="#exec" class="header-anchor">#</a> <code>exec</code></h5> <p>​	格式为: docker-compose exec 服务id bash(命令)</p> <ul><li>进入指定的容器</li></ul> <hr> <h5 id="ps"><a href="#ps" class="header-anchor">#</a> <code>ps</code></h5> <p>格式为 <code>docker-compose ps [options] [SERVICE...]</code></p> <p>列出项目中目前的所有容器</p> <p>选项：</p> <ul><li><code>-q</code> 只打印容器的 ID 信息</li></ul> <hr> <h5 id="restart"><a href="#restart" class="header-anchor">#</a> <code>restart</code></h5> <p>格式为 <code>docker-compose restart [options] [SERVICE...]</code></p> <p>重启项目中的服务</p> <p>选项：</p> <ul><li><code>-t, --timeout TIMEOUT</code> 指定重启前停止容器的超时（默认为 10 秒）</li></ul> <hr> <h5 id="rm"><a href="#rm" class="header-anchor">#</a> <code>rm</code></h5> <p>格式为 <code>docker-compose rm [options] [SERVICE...]</code></p> <p>删除所有（停止状态的）服务容器。推荐先执行 <code>docker-compose stop</code> 命令来停止容器</p> <p>选项：</p> <ul><li><code>-f, --force</code> 强制直接删除，包括非停止状态的容器。一般尽量不要使用该选项</li> <li><code>-v</code> 删除容器所挂载的数据卷</li></ul> <hr> <h5 id="start"><a href="#start" class="header-anchor">#</a> <code>start</code></h5> <p>格式为 <code>docker-compose start [SERVICE...]</code></p> <p>启动已经存在的服务容器</p> <hr> <h5 id="stop"><a href="#stop" class="header-anchor">#</a> <code>stop</code></h5> <ul><li>停止某个服务</li></ul> <p>格式为 <code>docker-compose stop [options] [SERVICE...]</code></p> <p>停止已经处于运行状态的容器，但不删除它。通过 <code>docker-compose start</code> 可以再次启动这些容器</p> <p>选项：</p> <ul><li><code>-t, --timeout TIMEOUT</code> 停止容器时候的超时（默认为 10 秒）</li></ul> <hr> <h5 id="top"><a href="#top" class="header-anchor">#</a> <code>top</code></h5> <p>查看各个服务容器内运行的进程</p> <hr> <h5 id="unpause"><a href="#unpause" class="header-anchor">#</a> <code>unpause</code></h5> <p>格式为 <code>docker-compose unpause [SERVICE...]</code></p> <p>恢复处于暂停状态中的服务</p> <h5 id="logs-重点"><a href="#logs-重点" class="header-anchor">#</a> <code>logs</code> [重点]</h5> <p>格式为 <code>docker-compose logs -f [SERVICE]</code></p></div></div> <div class="page-edit"><!----> <div class="last-updated"><span class="prefix">最近更新时间：</span> <span class="time">2021/10/10 12:20:50</span></div></div> <div class="page-nav-wapper"><!----> <!----></div></div> <div class="theme-vdoing-wrapper article-list bg-style-10"><div class="article-title"><a href="/blog/archives/" class="fa fa-pencil-alt">
      最近更新
    </a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><div><a href="/blog/pages/6158565fa6669/"><div>数字广东公司工作总结</div></a></div> <div class="date"><span>2021/12/08 09:39:37</span></div></dt></dl><dl><dd>02</dd> <dt><div><a href="/blog/pages/ad577fcaceee3/"><div>Spring Data基础</div></a></div> <div class="date"><span>2021/11/24 16:51:26</span></div></dt></dl><dl><dd>03</dd> <dt><div><a href="/blog/pages/6976a1db349ce/"><div>如何参加github开源项目</div></a></div> <div class="date"><span>2021/11/17 18:29:14</span></div></dt></dl> <div class="more-box"><a href="/blog/archives/" class="more"><i class="fas fa-angle-double-right"></i>前往更多 ...
      </a></div></div></div> <div class="comments-wrapper" style="display:none;"><!----></div></main></div> <div class="footer-wrapper" data-v-4c8cc972 data-v-4c8cc972><span class="footer-reco-theme" data-v-4c8cc972><i class="iconfont reco-github" data-v-4c8cc972></i> <a target="blank" href="https://github.com/YanHui-Yang" data-v-4c8cc972>HuiBlog@1.0</a></span> <!----> <span class="footer-copyright" data-v-4c8cc972><i class="iconfont reco-copyright" data-v-4c8cc972></i> <a data-v-4c8cc972><span data-v-4c8cc972>辉辉</span> <span class="ml5" data-v-4c8cc972>
          2021 - 至今
        </span></a></span> <span class="footer-view-site" data-v-4c8cc972><i class="iconfont reco-eye" data-v-4c8cc972></i> <span id="busuanzi_container_site_uv" data-v-4c8cc972>
        访客数：<span id="busuanzi_value_site_uv" class="num" data-v-4c8cc972>-</span></span> <span id="busuanzi_container_site_pv" class="ml5" data-v-4c8cc972>
        访问量：<span id="busuanzi_value_site_pv" class="num" data-v-4c8cc972>-</span></span></span> <!----></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div><!----><div></div></div></div>
    <script src="/blog/assets/js/app.4c41a59b.js" defer></script><script src="/blog/assets/js/2.a039f8e7.js" defer></script><script src="/blog/assets/js/26.37e22ab7.js" defer></script><script src="/blog/assets/js/4.bae9b8d2.js" defer></script>
  </body>
</html>
